package com.ctshk.sapp.finance.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.finance.dto.advance.AdvancePaymentDetailDTO;
import com.ctshk.rpc.finance.dto.advance.AdvancePaymentManageListDTO;
import com.ctshk.rpc.finance.dto.supplier.AccountSummaryDTO;
import com.ctshk.rpc.finance.req.supplier.AccountIdReq;
import com.ctshk.rpc.finance.req.advance.AdvancePaymentIdReq;
import com.ctshk.rpc.finance.req.advance.AdvancePaymentListReq;
import com.ctshk.rpc.finance.service.IFinanceAdvancePaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 财务预收款管理 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-03-26
 */
@RestController
@Api(value = "预收管理", tags = "预收管理")
@RequestMapping("/finance-advance-payment")
public class FinanceAdvancePaymentController extends BaseController {

    @DubboReference
    private IFinanceAdvancePaymentService advancePaymentService;


    @ApiOperation(value = "列表", notes = "列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "预收列表", operDesc = "预收列表")
    @PostMapping("/list")
    public Result<PageResponse<AdvancePaymentManageListDTO>> list(@RequestBody AdvancePaymentListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return advancePaymentService.list(req, getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "查看-基本信息", notes = "查看-基本信息（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "预收管理-查看-基本信息", operDesc = "预收管理-查看-基本信息")
    @PostMapping("/detail-base")
    public Result<AdvancePaymentDetailDTO> detail(@RequestBody @Valid AdvancePaymentIdReq req) {
        return advancePaymentService.detailBase(req);
    }


    @ApiOperation(value = "申请销账-查询客户预收款额度", notes = "申请销账-查询客户预收款额度（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "预收管理-申请销账-查询客户预收款额度", operDesc = "预收管理-申请销账-查询客户预收款额度")
    @PostMapping("/account-summary")
    public Result<List<AccountSummaryDTO>> accountSummary(@RequestBody @Valid AccountIdReq req) {
        return advancePaymentService.accountSummary(req);
    }

}
